home *** CD-ROM | disk | FTP | other *** search
/ PC Play 129 / pc play 129.iso / Demo / man2 / man2.exe / data / scripts / robot_scripts.lua < prev    next >
Encoding:
Text File  |  2006-08-31  |  8.5 KB  |  227 lines

  1. function units_robot_setup()
  2.     units_setup(7,false,ENET_EFFECT_PS_SETUPSMOKE_LARGE,ENET_EFFECT_GEOMETRY_ROBOTSHADOW)
  3.     units_reloadfirespots(uniGetExecutor(),2,ENET_EFFECT_BULLET_ROBOTROCKET)
  4. end
  5.  
  6. function units_robot_resetup()
  7.     units_setup(7,false,nil,ENET_EFFECT_GEOMETRY_ROBOTSHADOW)
  8.     units_reloadfirespots(uniGetExecutor(),2,ENET_EFFECT_BULLET_ROBOTROCKET)
  9. end
  10.  
  11. function units_robot_select()
  12.     units_select(22,2)
  13. end
  14.  
  15. function units_robot_unselect()
  16.     units_unselect()
  17. end
  18.  
  19. function units_robot_selectenemy()
  20.     uniGetExecutor():addSimpleEffect(ENET_EFFECT_SELECTEDGEOMETRY_ENEMY)
  21. end
  22.  
  23. function units_robot_damaged()
  24.     uniGetExecutor():applyDamage(uniGetLife())
  25. end
  26.  
  27. function units_robot_highlight()
  28.     uniGetExecutor():addEffectWithRadius(ENET_EFFECT_GEOMETRY_HIGHLIGHT,15)
  29. end
  30.  
  31. function units_robot_explode()
  32.     --units_explode_big()
  33.     units_explode_big1()
  34. end
  35.  
  36. function units_robot_move()
  37.     local unit = uniGetExecutor()
  38.     local steps = {}
  39.     local i = 0;
  40.     steps[0] = unit:getBone(ENBT_STEPEMITTER,0):addSimpleEffect(ENET_EFFECT_DYNAMICGEOMETRY_ROBOTSTEPSEMITTER_RIGHT)
  41.     steps[1] = unit:getBone(ENBT_STEPEMITTER,1):addSimpleEffect(ENET_EFFECT_DYNAMICGEOMETRY_ROBOTSTEPSEMITTER_LEFT)
  42.     local sound = unit:play3DSound("robot_rotate.wav",1)
  43.     unit:addAnimationToQueue(ENAT_TURNING,MATH_INFINITY)
  44.     waitDeath(unit:addRotationEffect(ENET_EFFECT_ROTATE_UNIT,MATH_PI * 0.7))
  45.     unit:addAnimationToQueue(ENAT_GO,MATH_INFINITY)
  46.     unit:setCurrentAnimationRepeatCount(0)
  47.     for i = 0,1 do
  48.         steps[i+2] = unit:getBone(ENBT_STEPEMITTER,i):addSimpleEffect(ENET_EFFECT_PS_TRACKSMOKE)
  49.     end
  50.     waitDeath(unit:addMoveEffect(ENET_EFFECT_MOVE_LINEAR,80))
  51.     unit:setCurrentAnimationRepeatCount(0)
  52.     sound:destroy()
  53.     unit:play3DSound("robot_stop.wav",0):destroy()
  54.     for i = 0,1 do
  55.         if(unit:getScale() < 1.0) then 
  56.             steps[i]:destroy()
  57.         else
  58.             steps[i]:setTransformOwner()
  59.             steps[i]:suspendedDestroy(70)
  60.         end
  61.         steps[i+2]:suspendedDestroy(1.0)
  62.     end
  63. end
  64.  
  65. function units_robot_fire1()
  66.     local unit = uniGetExecutor()
  67.     local gt = unit:getBone(ENBT_GUNTOWER)
  68.     local sound = gt:play3DSound("robot_guntower_rotate.wav",1)
  69.     waitDeath(gt:addRotationEffect(ENET_EFFECT_ROTATE_GUNTOWERTOTARGET,MATH_PI,uniGetTarget()))
  70.     sound:stopSound()
  71.     waitDeath(gt:getBone(ENBT_GUN):addRotationEffect(ENET_EFFECT_ROTATE_GUNTOTARGET,MATH_PI / 3.0,uniGetTarget()))
  72.     gt:getBone(ENBT_FIRE1):addBulletEffect(ENET_EFFECT_BULLET_HEAVYLASERRAY_RED):executeCommand(ENC_FIRE1)
  73.     unit:addFireArrow()
  74. end
  75.  
  76. function units_robot_fire1_new()
  77.     local unit = uniGetExecutor()
  78.     local sound = unit:play3DSound("robot_rotate.wav",1)
  79.     unit:addAnimationToQueue(ENAT_TURNING,MATH_INFINITY)
  80.     waitDeath(unit:parabolicTargetting(uniGetTarget(),unit:getBone(ENBT_FIRE1),MATH_PI * 0.7))
  81.     unit:setCurrentAnimationRepeatCount(1)
  82.     while(unit:getCurrentAnimation() == ENAT_TURNING) do pause() end
  83.     sound:stopSound()
  84.     waitDeath(unit:getBone(ENBT_GUN):addRotationEffect(ENET_EFFECT_ROTATE_GUNTOTARGET,MATH_PI / 3.0,uniGetTarget()))
  85.      local firespot = unit:getBone(ENBT_FIRE1)
  86.  
  87.     firespot:addSimpleEffect(ENET_EFFECT_HEAVYBOT2SHOT_FLY):executeCommand(ENC_FIRE1)
  88.  
  89.     unit:addFireArrow()
  90. end
  91.  
  92. function units_robot_fire2()
  93.     local unit = uniGetExecutor()
  94.     uniSetLife(uniGetLife() / 4.0)
  95.     if(unit:getObjectPositionInLocalSpace(uniGetTarget()).z < 0) then
  96.         local sound = unit:play3DSound("robot_rotate.wav",1)
  97.         unit:addAnimationToQueue(ENAT_TURNING,MATH_INFINITY)
  98.         waitDeath(unit:addRotationEffect(ENET_EFFECT_ROTATE_UNITTOTARGET,MATH_PI * 0.7,uniGetTarget()))
  99.         unit:setCurrentAnimationRepeatCount(1)
  100.         while(unit:getCurrentAnimation() == ENAT_TURNING) do pause() end
  101.         sound:stopSound()
  102.     end
  103.     local f_pause = 0.35
  104.     unit:getBone(ENBT_FIRE2,0):findEffect(ENET_EFFECT_BULLET_ROBOTROCKET):executeCommand(ENC_FIRE1)
  105.     pause(f_pause)
  106.     unit:getBone(ENBT_FIRE2,3):findEffect(ENET_EFFECT_BULLET_ROBOTROCKET):executeCommand(ENC_FIRE1)
  107.     pause(f_pause)
  108.     unit:getBone(ENBT_FIRE2,1):findEffect(ENET_EFFECT_BULLET_ROBOTROCKET):executeCommand(ENC_FIRE1)
  109.     pause(f_pause)
  110.     unit:getBone(ENBT_FIRE2,2):findEffect(ENET_EFFECT_BULLET_ROBOTROCKET):executeCommand(ENC_FIRE1)
  111.     pause(1.0)
  112.     units_reloadfirespots(uniGetExecutor(),2,ENET_EFFECT_BULLET_ROBOTROCKET)
  113.     unit:addFireArrow()
  114. end
  115.  
  116. registerCommand(ENSCRIPTSET_ROBOT,ENC_MOVE,"units_robot_move")
  117. registerCommand(ENSCRIPTSET_ROBOT,ENC_FIRE1,"units_robot_fire1_new")
  118. registerCommand(ENSCRIPTSET_ROBOT,ENC_FIRE2,"units_robot_fire2")
  119. registerCommand(ENSCRIPTSET_ROBOT,ENC_SELECT,"units_robot_select")
  120. registerCommand(ENSCRIPTSET_ROBOT,ENC_SELECTENEMY,"units_robot_selectenemy")
  121. registerCommand(ENSCRIPTSET_ROBOT,ENC_UNSELECT,"units_robot_unselect")
  122. registerCommand(ENSCRIPTSET_ROBOT,ENC_SETUP,"units_robot_setup")
  123. registerCommand(ENSCRIPTSET_ROBOT,ENC_RESETUP,"units_robot_resetup")
  124. registerCommand(ENSCRIPTSET_ROBOT,ENC_DAMAGED,"units_robot_damaged")
  125. registerCommand(ENSCRIPTSET_ROBOT,ENC_EXPLODE,"units_robot_explode")
  126. registerCommand(ENSCRIPTSET_ROBOT,ENC_HIGHLIGHT,"units_robot_highlight")
  127. registerCommand(ENSCRIPTSET_ROBOT,ENC_INSIDE,"units_inside")
  128.  
  129. -- make description of unit
  130. desc = getEffectDescriptionP(ENET_UNIT_ROBOT)
  131. desc.ClassID = ENCLASS_MESHINSTANCE
  132. desc.EffectClassType = ENECT_GEOMETRY
  133. desc.FileName = "robot.rmd"
  134. desc.ScriptSet = ENSCRIPTSET_ROBOT
  135. desc.MoveType = ENMOVE_GROUND
  136. desc.RenderType = ENRENDERTYPE_GEOMETRY
  137. desc.Material = ENMAT_RIGIDSKINNEDMESH
  138. desc.MaterialColors = units_materialcolors_human
  139.  
  140. -- shadow
  141. desc = getEffectDescriptionP(ENET_EFFECT_GEOMETRY_ROBOTSHADOW)
  142. desc.ClassID = ENCLASS_MESHINSTANCE
  143. desc.EffectClassType = ENECT_GEOMETRY
  144. desc.FileName = "robot_shadow.rmd"
  145. desc.RenderType = ENRENDERTYPE_SHADOW
  146. desc.Material = ENMAT_SHADOW
  147. desc.MaterialColors = units_materialcolors_shadow
  148.  
  149. ------------------------------------------------------------------------------------------------------
  150. ------------------------ effects related to unit------------------------------------------------------
  151. ------------------------------------------------------------------------------------------------------
  152.  
  153. function bullets_robotrocket_fire()
  154.     local bullet = uniGetExecutor()
  155.     bullet:setTransformOwner()
  156.     --local engine = bullet:addSimpleEffect(ENET_EFFECT_ORIENTEDSPRITE_ROCKETENGINEFIRE)
  157.     local light = bullet:addSimpleEffect(ENET_EFFECT_LIGHT_ROCKETENGINE)
  158. --    local sound = bullet:play3DSound("smallrocket_fly.wav",1)
  159.     bullet:play3DSound("smallrocket_fly.wav",0)
  160.     local track = bullet:addSimpleEffect(ENET_EFFECT_PS_ROCKETENGINE2)
  161. --    waitDeath(bullet:addMoveEffect(ENET_EFFECT_MOVE_ROCKETFLY,250,uniGetTarget()))
  162.     waitDeath(bullet:rocketFly(uniGetTarget():getBone(ENBT_TARGET):getWorldPosition()))
  163. --    sound:destroy()
  164.     light:destroy()
  165.     --engine:destroy()
  166.     track:suspendedDestroy(1.0)
  167.     bullet:play3DSound("smallrocket_explode.wav",0):destroy()
  168.     bullet:setVisibility(false,true)
  169.     bullet:addSimpleEffect(ENET_EFFECT_LIGHT_ROCKETEXPLODE):delayedDestroy(1.0)
  170.     bullet:addSimpleEffect(ENET_EFFECT_PS_ROCKETEXPLODE):suspendedDestroy(1.0)
  171.     uniGetTarget():executeCommand(ENC_DAMAGED)
  172.     pause(1.0)
  173.     bullet:destroy()
  174. end
  175.  
  176. registerCommand(ENSCRIPTSET_ROBOT_ROCKET,ENC_FIRE1,"bullets_robotrocket_fire")
  177.  
  178.  
  179.  
  180. function bullets_heavylaserray_fire()
  181.     local bullet = uniGetExecutor()
  182.     bullet:setTransformOwner()
  183.     bullet:play3DSound("robot_heavylaserfire.wav",0):destroy()
  184.     local light = bullet:addSimpleEffect(ENET_EFFECT_LIGHT_BLUELASERBOLTFLY)
  185.     local track = bullet:addSimpleEffect(ENET_EFFECT_PS_HEAVYLASERRAY_RED)
  186.     waitDeath(bullet:addMoveEffect(ENET_EFFECT_MOVE_LINEARFLY,2500,uniGetTarget()),1000)
  187.     light:destroy()
  188.     track:suspendedDestroy(1.5)
  189.     local hit_ps = bullet:addSimpleEffect(ENET_EFFECT_PS_HEAVYLASERRAY_RED_HIT)
  190.     pause(0.5)
  191.     hit_ps:suspendedDestroy(1.0)
  192.     uniGetTarget():executeCommand(ENC_DAMAGED)
  193.     pause(1.0)
  194.     bullet:destroy()
  195. end
  196.  
  197. registerCommand(ENSCRIPTSET_BULLET_HEAVYLASERRAY_RED,ENC_FIRE1,"bullets_heavylaserray_fire")
  198.  
  199. -- register new unit to logic
  200. unitDesc = logic_getUnitDescP(1)
  201. unitDesc.group = 0
  202. unitDesc.order = 3
  203. unitDesc.unit_res_id = ENET_UNIT_ROBOT
  204. unitDesc.unit_icon_id = "Robot_h_small_normal.dds"
  205. unitDesc.active_id = "Robot_h_small_active.dds"
  206. unitDesc.pressed_id = "Robot_h_small_pressed.dds"
  207. unitDesc.big_icon_id = "Robot_h_big_normal.dds"
  208. unitDesc.small_icon_id = "Robot_u_stats.dds"
  209. unitDesc.HP = 7
  210. unitDesc.MP = 20
  211. unitDesc.WR = 2
  212. unitDesc.min_WR = 1
  213. unitDesc.WD = 3
  214. unitDesc.WR2 = 0
  215. unitDesc.min_WR2 = 0
  216. unitDesc.WD2 = 0
  217. unitDesc.ability = 1
  218. unitDesc.transport = 0
  219. unitDesc.value = 4
  220. unitDesc.race = 0
  221. unitDesc.fire_pause = 0.6
  222. unitDesc.move_pause = 0.7
  223. unitDesc.unit_info_scale = 0.07
  224. unitDesc.scn_name = "HBOT"
  225.  
  226.  
  227.